package cn.weekimwee.firstlineofcodeforkotlin.unit9

import android.os.Bundle
import android.view.View
import cn.weekimwee.firstlineofcodeforkotlin.BaseActivity
import cn.weekimwee.firstlineofcodeforkotlin.R
import kotlinx.android.synthetic.main.activity_unit9.*
import org.jetbrains.anko.startActivity

class Unit9Activity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_unit9)
        startWebView.setOnClickListener { it.onClick() }
        startHttpUrlConnection.setOnClickListener { it.onClick() }
        startOkHttp.setOnClickListener { it.onClick() }
        startRtrofit.setOnClickListener { it.onClick() }
    }

    private fun View.onClick(){
        when(this.id){
            R.id.startWebView-> startActivity<WebViewActivity>()
            R.id.startHttpUrlConnection->startActivity<HttpURLConnectionActivity>()
            R.id.startOkHttp -> startActivity<OkHttpActivity>()
            R.id.startRtrofit -> startActivity<StartRetrofitActivity>()
        }
    }
}
